<?php
//Saber cuantas zonas posee cada area
foreach ($zonas as $zona){
 
    if(!isset(${'zonaToal'.$zona->getAreaId()})) 
    ${'zonaToal'.$zona->getAreaId()} =  1;
    else
    ${'zonaToal'.$zona->getAreaId()} = ${'zonaToal'.$zona->getAreaId()}+1;
    
}

?>

<table class="tableTitulo" style="" border="0" cellpadding="0" cellspacing="0">
    <tr>
      
    </tr>
     <tr>
        <td class="columnaTitulo" align="center">COD</td>
        <td class="columnaTitulo">Nombre</td>
        <td class="columnaTitulo"># Zonas</td>
        <td style="background: #488eb8">
            <a title="Agregar nueva area" class="button-done submitId" style="float: right;" href="<?php echo url_for('area/new') ?>">Agregar</a>
        </td>
        
    </tr>
    <?php foreach ($areas as $area){?>
    <tr>
        
        <td class="columnaFila" align="center">
            <font class="statusId">
            <?php echo str_pad($area->getId(), 4,"0", STR_PAD_LEFT); ?>
            </font>
           
        </td>
        
        
        <td class="columnaFila">
        <?php echo ucwords($area->getNombre()) ?>
        </td>
        <td class="columnaFila" align="center">
            
            <?php if(isset(${'zonaToal'.$area->getId()})){?>
            <font class="servicios servicio3">
            <?php echo str_pad(${'zonaToal'.$area->getId()}, 3,"0", STR_PAD_LEFT); 
            $areaTotal  = ${'zonaToal'.$area->getId()};
            ?>
            </font>
            
            <?php }else {
                
                $areaTotal = 0;
                ?>
            
            <font class="servicios servicio3" style="background: #ccc;">
                <?php echo "000";?>
            </font>
            
            <?php } ?>
        </td>
        
        <td class="columnaFila" align="right">
            <a title="Realice click para modificar el area '<?php echo ucwords($area->getNombre()) ?>'" class="button-done" style=" font-size:10px;padding: 5px; float: right;"  href="<?php echo url_for('area/edit?id='.$area->getId()) ?>" >
            Modificar</a>
            
            <?php
            if($areaTotal<=0)
            echo link_to('Eliminar', 'area/delete?id='.$area->getId(), array('method' => 'delete','title'=>'Al realizar click eliminara del sistema el area' , 'style' => 'font-size:11px;padding: 5px;float: right; background: #d05848; border: #d05848;','class' => 'button-done submitId','confirm' => 'Esta seguro que desea eliminar el area\n"'.strtoupper($area->getNombre()).'" del sistema?')) ?>
            </td>
        
    </tr>
    
    <?php } ?>
</table>

<!--Paginacion de  ------------------------------------------------>
<table id="paginacion" class="gradientGray">
    <tr>
        <td  align="left" style="padding-left: 10px;">
    
<?php if ($areas->haveToPaginate()): ?>
    <?php echo link_to('&laquo;', 'area/index?page='.$areas->getFirstPage(), array('class'  => 'paginacionBoton')) ?>
    <?php echo link_to('&lt;', 'area/index?page='.$areas->getPreviousPage(), array('class'  => 'paginacionBoton')) ?>
    <?php $links = $areas->getLinks();
        foreach ($links as $page): ?>
        <?php echo ($page == $areas->getPage()) ? "<font class=\"paginacionBotonOff\">".$page."</font>" : link_to($page, 'area/index?page='.$page, array('class'  => 'paginacionBoton')) ?>
        <?php if ($page != $areas->getCurrentMaxLink()): ?>     <?php endif ?>
        <?php endforeach ?>
    <?php echo link_to('&gt;', 'area/index?page='.$areas->getNextPage(), array('class'  => 'paginacionBoton')) ?>
    <?php echo link_to('&raquo;', 'area/index?page='.$areas->getLastPage(), array('class'  => 'paginacionBoton')) ?>
 <?php endif ?>
    </td>
    <td align="right" style="margin-right: 10px;">
        
     <?php echo "<font class=\"paginacionStatus\" > Total Registros ". number_format($areas->getNbResults(),0,'','.')." <b>( ".number_format($areas->getFirstIndice(),0,'','.')."</b> hasta <b>".number_format($areas->getLastIndice(),0,'','.')." )</b></font>"; ?>
    </td>
    </tr>
</table>
<!--Paginacion de  ------------------------------------------------>